package homeword;

import java.io.LineNumberReader;
import java.util.*;
import java.util.function.BiConsumer;

public class MapDome {
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
        Map<String, homeword.entity.Map> map = new HashMap<>();

        map.put("1930",new homeword.entity.Map("1930年","第一届","乌拉圭","乌拉圭"));
        map.put("1934",new homeword.entity.Map("1934年","第二届","意大利","意大利"));
        map.put("1938",new homeword.entity.Map("1938年","第三届","法国","意大利"));
        map.put("1950",new homeword.entity.Map("1950年","第四届","巴西","乌拉圭"));
        map.put("1954",new homeword.entity.Map("1954年","第五届","瑞士","西德"));
        map.put("1958",new homeword.entity.Map("1958年","第六届","瑞典","巴西"));
        map.put("1962",new homeword.entity.Map("1962年","第七届","智利","巴西"));
        map.put("1966",new homeword.entity.Map("1966年","第八届","英格兰","英格兰"));
        map.put("1970",new homeword.entity.Map("1970年","第九届","墨西哥","巴西"));
        map.put("1974",new homeword.entity.Map("1974年","第十届","前西德","西德"));
        map.put("1978",new homeword.entity.Map("1978年","第十一届","阿根廷","阿根廷"));
        map.put("1982",new homeword.entity.Map("1982年","第十二届","西班牙","意大利"));
        map.put("1986",new homeword.entity.Map("1986年","第十三届","墨西哥","阿根廷"));
        map.put("1990",new homeword.entity.Map("1990年","第十四届","意大利","西德"));
        map.put("1994",new homeword.entity.Map("1994年","第十五届","美国","巴西"));
        map.put("1998",new homeword.entity.Map("1998年","第十六届","法国","法国"));
        map.put("2002",new homeword.entity.Map("2002年","第十七届","韩日","巴西"));
        map.put("2006",new homeword.entity.Map("2006年","第十八届","德国","意大利"));
        map.put("2010",new homeword.entity.Map("2010年","第十九届","南非","西班牙"));
        map.put("2014",new homeword.entity.Map("2014年","第二十届","巴西","德国"));

        System.out.println("请输入年份：");
        String year = scanner.next();

        map.forEach(new BiConsumer<String, homeword.entity.Map>() {
            @Override
            public void accept(String s, homeword.entity.Map map) {
                String s1 = (String) s;
                homeword.entity.Map map1 = (homeword.entity.Map) map;


                if (year.equals(s1)){
                    System.out.println(map1.getYear() + "获得世界杯的冠军的是，" + map1.getWin());
                }
            }
        });
        System.out.println("请输入一个国家名称：");
        String name = scanner.next();
        Set<Map.Entry<String, homeword.entity.Map>> entries = map.entrySet();
        for (Map.Entry<String, homeword.entity.Map> entry : entries) {
            homeword.entity.Map value = entry.getValue();

            if (name.equals(value.getWin())){
                System.out.println(value.getYear());
            }

        }
    }
}
